Skip to contentSkip to conversation

spidev.c ?

DISCUSSION jchludzinski 2 participants 8 messages Mar 17, 2021 – Mar 21, 2021 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

In the YOCTO/Linux source tree there's _drivers/spi/_ which has all the source for SPI drivers. There's only 1 file, _spidev.c_, which has:

static int __init spidev_init(void)

{
       int status;

       /* Claim our 256 reserved device numbers.  Then register a class
        * that will key udev/mdev to add/remove /dev nodes.  Last,
register
        * the driver which manages those device numbers.
        */
       BUILD_BUG_ON(N_SPI_MINORS > 256);
       status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
       if (status < 0)
               return status;

       spidev_class = class_create(THIS_MODULE, "spidev");
       if (IS_ERR(spidev_class)) {
               unregister_chrdev(SPIDEV_MAJOR,
spidev_spi_driver.driver.name);
               return PTR_ERR(spidev_class);
       }

       status = spi_register_driver(&spidev_spi_driver);
       if (status < 0) {
               class_destroy(spidev_class);
               unregister_chrdev(SPIDEV_MAJOR,
spidev_spi_driver.driver.name);
       }
       return status;
}

module_init(spidev_init);

... for creating device files in _udev_.

So when I use '_make nconfig_' to specifiy that I want a loadable module for the ALTERA SPI driver, why don't I see a _spidev.o_ file in _drivers/spi/_ ?

How does _spi-altera.ko_ create device files without a call to register_chrdev(...).

How is it a loadable module without module_init(...)?

When I separately build _spidev.c_ as an _.ko_ and try loading it, I
get: "_Device or resourse busy_"

---John

#1 lore raw

I am guessing here.... But what do you have while executing the following command being in /sys
as root?

root@arm:/sys# find . -name spi*

Zee
_______

Quoted 45 lines · jchludzinski via lists.yoctoproject.org

In the YOCTO/Linux source tree there's drivers/spi/ which has all the source for SPI drivers. There's only 1 file, spidev.c, which has:

static int __init spidev_init(void)

{
        int status;

        /* Claim our 256 reserved device numbers.  Then register a class
         * that will key udev/mdev to add/remove /dev nodes.  Last, register
         * the driver which manages those device numbers.
         */
        BUILD_BUG_ON(N_SPI_MINORS > 256);
        status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
        if (status < 0)
                return status;

        spidev_class = class_create(THIS_MODULE, "spidev");
        if (IS_ERR(spidev_class)) {
                unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
                return PTR_ERR(spidev_class);
        }

        status = spi_register_driver(&spidev_spi_driver);
        if (status < 0) {
                class_destroy(spidev_class);
                unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
        }
        return status;
}

module_init(spidev_init);

... for creating device files in udev.

So when I use 'make nconfig' to specifiy that I want a loadable module for the ALTERA SPI driver, why don't I see a spidev.o file in drivers/spi/ ?

How does spi-altera.ko create device files without a call to register_chrdev(...).

How is it a loadable module without module_init(...)?

When I separately build spidev.c as an .ko and try loading it, I get: "Device or resourse busy"

---John

#2 lore raw
root@arria10:~# find /sys/ -name 'spi*'

/sys/kernel/debug/clk/spi_m_clk
/sys/kernel/debug/tracing/events/spi /sys/kernel/debug/tracing/events/spi/spi_controller_idle /sys/kernel/debug/tracing/events/spi/spi_controller_busy /sys/kernel/debug/tracing/events/spi/spi_message_submit /sys/kernel/debug/tracing/events/spi/spi_message_start /sys/kernel/debug/tracing/events/spi/spi_message_done /sys/kernel/debug/tracing/events/spi/spi_transfer_start /sys/kernel/debug/tracing/events/spi/spi_transfer_stop /sys/kernel/debug/regmap/spi0.0 /sys/devices/platform/soc/ffda5000.spi/spi_master /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0 /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0 /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_sync /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_async /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_sync_immediate /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_sync /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_async /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_sync_immediate /sys/class/spidev
/sys/class/spi_master
/sys/class/spi_master/spi0
/sys/firmware/devicetree/base/__symbols__/spi2 /sys/firmware/devicetree/base/__symbols__/spi0 /sys/firmware/devicetree/base/__symbols__/spin_ctrl_1 /sys/firmware/devicetree/base/__symbols__/spi_m_clk /sys/firmware/devicetree/base/__symbols__/spi1 /sys/firmware/devicetree/base/__symbols__/spin_ctrl_2 /sys/firmware/devicetree/base/soc/spi@ff809000 /sys/firmware/devicetree/base/soc/spi@ffda5000 /sys/firmware/devicetree/base/soc/spi@ffda5000/resource-manager@0/spi-max-frequency /sys/firmware/devicetree/base/soc/clkmgr@ffd04000/clocks/spi_m_clk /sys/firmware/devicetree/base/soc/spi@ffda4000 /sys/firmware/devicetree/base/spi@0xc00c0800 /sys/firmware/devicetree/base/spi@0xc00c0800/spidev@0 /sys/firmware/devicetree/base/spi@0xc00c0800/spidev@0/spi-max-frequency /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@200/spin-controller /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@200/spin-rph /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@100/spin-controller /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@100/spin-controller-names /sys/firmware/devicetree/base/testcase-data-2/substation@100/motor-1/spin /sys/bus/platform/drivers/spi_altera
/sys/bus/spi
/sys/bus/spi/devices/spi0.0
/sys/bus/spi/drivers/spi-nor
/sys/bus/spi/drivers/altr_a10sr/spi0.0
/sys/bus/spi/drivers/spidev
/sys/module/spidev
/sys/module/spidev/drivers/spi:spidev
/sys/module/spi_altera

Quoted 62 lines · Zoran

I am guessing here.... But what do you have while executing the following command being in /sys
as root?

root@arm:/sys# find . -name spi*

Zee
_______

Quoted 34 lines · jchludzinski via lists.yoctoproject.org

In the YOCTO/Linux source tree there's drivers/spi/ which has all the source for SPI drivers. There's only 1 file, spidev.c, which has:

static int __init spidev_init(void)
{
int status;

/* Claim our 256 reserved device numbers. Then register a class
* that will key udev/mdev to add/remove /dev nodes. Last, register
* the driver which manages those device numbers.
*/
BUILD_BUG_ON(N_SPI_MINORS > 256);
status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops); if (status < 0)
return status;

spidev_class = class_create(THIS_MODULE, "spidev"); if (IS_ERR(spidev_class)) { unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name); return PTR_ERR(spidev_class);
}

status = spi_register_driver(&spidev_spi_driver);
if (status < 0) {
class_destroy(spidev_class); unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name); }
return status;
}
module_init(spidev_init);

... for creating device files in udev.

So when I use 'make nconfig' to specifiy that I want a loadable module for the ALTERA SPI driver, why don't I see a spidev.o file in drivers/spi/ ?

Quoted 7 lines

How does spi-altera.ko create device files without a call to register_chrdev(...).

How is it a loadable module without module_init(...)?

When I separately build spidev.c as an .ko and try loading it, I get: "Device or resourse busy"

---John

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#52762): https://lists.yoctoproject.org/g/yocto/message/52762
Mute This Topic: https://lists.yoctoproject.org/mt/81407811/5071304
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub
[[email protected]]

#3 lore raw

Hello John,

It seems that your target is configured correctly. Since you have all the components you should and must have as SPI framework.

Namely I was looking for /sys/bus (since you must have an SPI bus driver), and then /sys/class (since as my best understanding is that SPI is a master/slave device), you must have class/). Others are assumed, you added debug directories.

Quoted 2 lines

When I separately build spidev.c as an .ko and try loading it, I get: "Device or resource busy"

This is understandable, since you already have included spidev.ko as menuconfig value Y, so it is already present in the kernel, but as a built-in part of the kernel (my best guess).

Quoted 4 lines
root@arria10:~# lsmod
Module                  Size  Used by
spi_altera             16384  0
spidev                 20480  0

I see that you did change the menuconfig, and made spidev to be M.

What I also see is that there are no dependencies between spidev and spi_altera. This is what you really wanted?

Quoted 2 lines

But there are NO udev files for the SPI devices
defined in the DTSI file.

Could you, please, better explain this sentence? In more details (as much as you can)?

Thank you,
Zee
_______

Quoted 126 lines · jchludzinski
root@arria10:~# find /sys/ -name 'spi*'

/sys/kernel/debug/clk/spi_m_clk
/sys/kernel/debug/tracing/events/spi /sys/kernel/debug/tracing/events/spi/spi_controller_idle /sys/kernel/debug/tracing/events/spi/spi_controller_busy /sys/kernel/debug/tracing/events/spi/spi_message_submit /sys/kernel/debug/tracing/events/spi/spi_message_start /sys/kernel/debug/tracing/events/spi/spi_message_done /sys/kernel/debug/tracing/events/spi/spi_transfer_start /sys/kernel/debug/tracing/events/spi/spi_transfer_stop /sys/kernel/debug/regmap/spi0.0 /sys/devices/platform/soc/ffda5000.spi/spi_master /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0 /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0 /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_sync /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_async /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_sync_immediate /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_sync /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_async /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_sync_immediate /sys/class/spidev
/sys/class/spi_master
/sys/class/spi_master/spi0
/sys/firmware/devicetree/base/__symbols__/spi2 /sys/firmware/devicetree/base/__symbols__/spi0 /sys/firmware/devicetree/base/__symbols__/spin_ctrl_1 /sys/firmware/devicetree/base/__symbols__/spi_m_clk /sys/firmware/devicetree/base/__symbols__/spi1 /sys/firmware/devicetree/base/__symbols__/spin_ctrl_2 /sys/firmware/devicetree/base/soc/spi@ff809000 /sys/firmware/devicetree/base/soc/spi@ffda5000 /sys/firmware/devicetree/base/soc/spi@ffda5000/resource-manager@0/spi-max-frequency /sys/firmware/devicetree/base/soc/clkmgr@ffd04000/clocks/spi_m_clk /sys/firmware/devicetree/base/soc/spi@ffda4000 /sys/firmware/devicetree/base/spi@0xc00c0800 /sys/firmware/devicetree/base/spi@0xc00c0800/spidev@0 /sys/firmware/devicetree/base/spi@0xc00c0800/spidev@0/spi-max-frequency /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@200/spin-controller /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@200/spin-rph /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@100/spin-controller /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@100/spin-controller-names /sys/firmware/devicetree/base/testcase-data-2/substation@100/motor-1/spin /sys/bus/platform/drivers/spi_altera
/sys/bus/spi
/sys/bus/spi/devices/spi0.0
/sys/bus/spi/drivers/spi-nor
/sys/bus/spi/drivers/altr_a10sr/spi0.0
/sys/bus/spi/drivers/spidev
/sys/module/spidev
/sys/module/spidev/drivers/spi:spidev
/sys/module/spi_altera

On 2021-03-18 03:44, Zoran wrote:

I am guessing here.... But what do you have while executing the following command being in /sys
as root?

root@arm:/sys# find . -name spi*

Zee
_______

On Wed, Mar 17, 2021 at 5:41 PM jchludzinski via lists.yoctoproject.org <[email protected]> wrote:

In the YOCTO/Linux source tree there's drivers/spi/ which has all the source for SPI drivers. There's only 1 file, spidev.c, which has:

static int __init spidev_init(void)

{
        int status;

        /* Claim our 256 reserved device numbers.  Then register a class
         * that will key udev/mdev to add/remove /dev nodes.  Last, register
         * the driver which manages those device numbers.
         */
        BUILD_BUG_ON(N_SPI_MINORS > 256);
        status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
        if (status < 0)
                return status;

        spidev_class = class_create(THIS_MODULE, "spidev");
        if (IS_ERR(spidev_class)) {
                unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
                return PTR_ERR(spidev_class);
        }

        status = spi_register_driver(&spidev_spi_driver);
        if (status < 0) {
                class_destroy(spidev_class);
                unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
        }
        return status;
}

module_init(spidev_init);

... for creating device files in udev.

So when I use 'make nconfig' to specifiy that I want a loadable module for the ALTERA SPI driver, why don't I see a spidev.o file in drivers/spi/ ?

How does spi-altera.ko create device files without a call to register_chrdev(...).

How is it a loadable module without module_init(...)?

When I separately build spidev.c as an .ko and try loading it, I get: "Device or resourse busy"

---John

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#52762): https://lists.yoctoproject.org/g/yocto/message/52762
Mute This Topic: https://lists.yoctoproject.org/mt/81407811/5071304
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub
[[email protected]]

#4 lore raw

Using '_make nconfig_' I selected the following options:
(_Keep in mind I using an Altera/Intel Arria 10 SoC which uses DesignWare hard SPI controllers. BUT the SPI controllers I'm concerned with now are soft controllers defined in the FPGA code)_.

.config - Linux/arm 5.4.74 Kernel Configuration

┌── SPI support
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                      
                                                            │
│                            --- SPI support                           
                                                            │
│                            [*]   Debug support for SPI drivers       
                                                            │
│                            -*-   SPI memory extension                
                                                            │
│                                  *** SPI Master Controller Drivers
***                                                             │
│                            <M>   Altera SPI Controller               

...

│                            <*>   Utilities for Bitbanging SPI masters
                                                            │
│                            < >   Cadence SPI controller              
                                                            │
│                            < >   CLPS711X host SPI controller        
                                                            │
│                            <*>   DesignWare SPI controller core
support                                                            │
│                            <*>     PCI interface driver for DW SPI
core                                                            │
│                            <*>     Memory-mapped io interface driver
for DW SPI core                                               │

...

│                                  *** SPI Protocol Masters ***        
                                                            │
│                            <M>   User mode SPI device driver support 
                                                            │
│                            <M>   spi loopback test framework support 
                                                            │
│                            < >   Infineon TLE62X0 (for power
switching)                                                            │
│                            [*]   SPI slave protocol handlers         
                                                            │
│                            <M>     SPI slave handler reporting boot
up time                                                        │
│                            <M>     SPI slave handler controlling
system state                                                      │

This got the SPI nodes to show up in _/sys/firmware/devicetree/_ but there were no _udev_ files (_/dev/spidevXX_). So I commented out the '_interrupts_' in the DTSI file and the _udev_ files appeared?

spi2: spi@0xc00c0800 { // hps_spi_1553_int
address-cells = <0x1>;
#size-cells = <0x0>;
reg = <0xc00c0800 0x20>;
// interrupt-parent = <&intc>;
// interrupts = <0 24 IRQ_TYPE_EDGE_FALLING>;
num-cs = <0x1>;
status = "okay";

  spidev@0 { 
     compatible = "rohm,dh2228fv";
     #address-cells = <0x1>; 
     #size-cells = <0x0>;
     reg = <0x0>; 
     spi-max-frequency = <0x1f400>; 
     // enable-dma = <0x1>;

};
};

BUT I need those interrupts. Thoughts and/or suggestions?

---John

Quoted 45 lines · Zoran

Hello John,

It seems that your target is configured correctly. Since you have all the components you should and must have as SPI framework.

Namely I was looking for /sys/bus (since you must have an SPI bus driver), and then /sys/class (since as my best understanding is that SPI is a master/slave device), you must have class/). Others are assumed, you added debug directories.

Quoted 2 lines

When I separately build spidev.c as an .ko and try loading it, I get: "Device or resource busy"

This is understandable, since you already have included spidev.ko as menuconfig value Y, so it is already present in the kernel, but as a built-in part of the kernel (my best guess).

Quoted 4 lines
root@arria10:~# lsmod
Module                  Size  Used by
spi_altera             16384  0
spidev                 20480  0

I see that you did change the menuconfig, and made spidev to be M.

What I also see is that there are no dependencies between spidev and spi_altera. This is what you really wanted?

Quoted 2 lines

But there are NO udev files for the SPI devices
defined in the DTSI file.

Could you, please, better explain this sentence? In more details (as much as you can)?

Thank you,
Zee
_______

Quoted 6 lines · jchludzinski
root@arria10:~# find /sys/ -name 'spi*'

/sys/kernel/debug/clk/spi_m_clk /sys/kernel/debug/tracing/events/spi /sys/kernel/debug/tracing/events/spi/spi_controller_idle /sys/kernel/debug/tracing/events/spi/spi_controller_busy

...

Quoted 64 lines
Quoted 64 lines

/sys/bus/spi/devices/spi0.0
/sys/bus/spi/drivers/spi-nor
/sys/bus/spi/drivers/altr_a10sr/spi0.0
/sys/bus/spi/drivers/spidev
/sys/module/spidev
/sys/module/spidev/drivers/spi:spidev
/sys/module/spi_altera

On 2021-03-18 03:44, Zoran wrote:

I am guessing here.... But what do you have while executing the following command being in /sys
as root?

root@arm:/sys# find . -name spi*

Zee
_______

On Wed, Mar 17, 2021 at 5:41 PM jchludzinski via lists.yoctoproject.org <[email protected]> wrote:

In the YOCTO/Linux source tree there's drivers/spi/ which has all the source for SPI drivers. There's only 1 file, spidev.c, which has:

static int __init spidev_init(void)
{
int status;

/* Claim our 256 reserved device numbers. Then register a class
* that will key udev/mdev to add/remove /dev nodes. Last, register
* the driver which manages those device numbers.
*/
BUILD_BUG_ON(N_SPI_MINORS > 256);
status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops); if (status < 0)
return status;

spidev_class = class_create(THIS_MODULE, "spidev"); if (IS_ERR(spidev_class)) { unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name); return PTR_ERR(spidev_class);
}

status = spi_register_driver(&spidev_spi_driver);
if (status < 0) {
class_destroy(spidev_class); unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name); }
return status;
}
module_init(spidev_init);

... for creating device files in udev.

So when I use 'make nconfig' to specifiy that I want a loadable module for the ALTERA SPI driver, why don't I see a spidev.o file in drivers/spi/ ?

How does spi-altera.ko create device files without a call to register_chrdev(...).

How is it a loadable module without module_init(...)?

When I separately build spidev.c as an .ko and try loading it, I get: "Device or resourse busy"

---John

#5 lore raw
Quoted 2 lines

// interrupt-parent = <&intc>;
// interrupts = <0 24 IRQ_TYPE_EDGE_FALLING>;

Not sure if you did represent these values correctly?!

I have for enc28j60:something like this:
interrupt-parent = <&gpio2>;
interrupts = <1 IRQ_TYPE_EDGE_FALLING>;

Where <&gpio2> is gpio chip name (the gpio port 2),
and <1 IRQ_TYPE_EDGE_FALLING>;is pin 1 of port 2 (32 pins for ports from port 0).

<&intc> should be an INT controller.
Since <0 24 IRQ_TYPE_EDGE_FALLING>; you are trying to represent 0 as port #, 24 as pin #...

I have no idea how many pins you have per gpio port? 16? 32?

You should carefully analyse and try to understand if you wrote this device tree sequence correctly.

But I am just guessing now...

Zee
_______

Quoted 182 lines · jchludzinski

Using 'make nconfig' I selected the following options:
(Keep in mind I using an Altera/Intel Arria 10 SoC which uses DesignWare hard SPI controllers. BUT the SPI controllers I'm concerned with now are soft controllers defined in the FPGA code).

.config - Linux/arm 5.4.74 Kernel Configuration

 ┌── SPI support ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 │                                                                                                                                    │
 │                            --- SPI support                                                                                         │
 │                            [*]   Debug support for SPI drivers                                                                     │
 │                            -*-   SPI memory extension                                                                              │
 │                                  *** SPI Master Controller Drivers ***                                                             │
 │                            <M>   Altera SPI Controller

...

 │                            <*>   Utilities for Bitbanging SPI masters                                                              │
 │                            < >   Cadence SPI controller                                                                            │
 │                            < >   CLPS711X host SPI controller                                                                      │
 │                            <*>   DesignWare SPI controller core support                                                            │
 │                            <*>     PCI interface driver for DW SPI core                                                            │
 │                            <*>     Memory-mapped io interface driver for DW SPI core                                               │

...

 │                                  *** SPI Protocol Masters ***                                                                      │
 │                            <M>   User mode SPI device driver support                                                               │
 │                            <M>   spi loopback test framework support                                                               │
 │                            < >   Infineon TLE62X0 (for power switching)                                                            │
 │                            [*]   SPI slave protocol handlers                                                                       │
 │                            <M>     SPI slave handler reporting boot up time                                                        │
 │                            <M>     SPI slave handler controlling system state                                                      │

This got the SPI nodes to show up in /sys/firmware/devicetree/ but there were no udev files (/dev/spidevXX). So I commented out the 'interrupts' in the DTSI file and the udev files appeared?

spi2: spi@0xc00c0800 { // hps_spi_1553_int

   address-cells = <0x1>;
   #size-cells = <0x0>;
   reg = <0xc00c0800 0x20>;
   // interrupt-parent = <&intc>;
   // interrupts = <0 24 IRQ_TYPE_EDGE_FALLING>;
   num-cs = <0x1>;
   status = "okay";

   spidev@0 {
      compatible = "rohm,dh2228fv";
      #address-cells = <0x1>;
      #size-cells = <0x0>;
      reg = <0x0>;
      spi-max-frequency = <0x1f400>;
      // enable-dma = <0x1>;
   };
};

BUT I need those interrupts. Thoughts and/or suggestions?

---John

On 2021-03-19 01:10, Zoran wrote:

Hello John,

It seems that your target is configured correctly. Since you have all the components you should and must have as SPI framework.

Namely I was looking for /sys/bus (since you must have an SPI bus driver), and then /sys/class (since as my best understanding is that SPI is a master/slave device), you must have class/). Others are assumed, you added debug directories.

When I separately build spidev.c as an .ko and try loading it, I get: "Device or resource busy"

This is understandable, since you already have included spidev.ko as menuconfig value Y, so it is already present in the kernel, but as a built-in part of the kernel (my best guess).

root@arria10:~# lsmod
Module                  Size  Used by
spi_altera             16384  0
spidev                 20480  0

I see that you did change the menuconfig, and made spidev to be M.

What I also see is that there are no dependencies between spidev and spi_altera. This is what you really wanted?

But there are NO udev files for the SPI devices
defined in the DTSI file.

Could you, please, better explain this sentence? In more details (as much as you can)?

Thank you,
Zee
_______

On Thu, Mar 18, 2021 at 10:07 PM jchludzinski <[email protected]> wrote:

root@arria10:~# find /sys/ -name 'spi*'

/sys/kernel/debug/clk/spi_m_clk /sys/kernel/debug/tracing/events/spi /sys/kernel/debug/tracing/events/spi/spi_controller_idle /sys/kernel/debug/tracing/events/spi/spi_controller_busy

...

/sys/bus/spi/devices/spi0.0
/sys/bus/spi/drivers/spi-nor
/sys/bus/spi/drivers/altr_a10sr/spi0.0
/sys/bus/spi/drivers/spidev
/sys/module/spidev
/sys/module/spidev/drivers/spi:spidev
/sys/module/spi_altera

On 2021-03-18 03:44, Zoran wrote:

I am guessing here.... But what do you have while executing the following command being in /sys
as root?

root@arm:/sys# find . -name spi*

Zee
_______

On Wed, Mar 17, 2021 at 5:41 PM jchludzinski via lists.yoctoproject.org <[email protected]> wrote:

In the YOCTO/Linux source tree there's drivers/spi/ which has all the source for SPI drivers. There's only 1 file, spidev.c, which has:

static int __init spidev_init(void)

{
        int status;

        /* Claim our 256 reserved device numbers.  Then register a class
         * that will key udev/mdev to add/remove /dev nodes.  Last, register
         * the driver which manages those device numbers.
         */
        BUILD_BUG_ON(N_SPI_MINORS > 256);
        status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
        if (status < 0)
                return status;

        spidev_class = class_create(THIS_MODULE, "spidev");
        if (IS_ERR(spidev_class)) {
                unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
                return PTR_ERR(spidev_class);
        }

        status = spi_register_driver(&spidev_spi_driver);
        if (status < 0) {
                class_destroy(spidev_class);
                unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
        }
        return status;
}

module_init(spidev_init);

... for creating device files in udev.

So when I use 'make nconfig' to specifiy that I want a loadable module for the ALTERA SPI driver, why don't I see a spidev.o file in drivers/spi/ ?

How does spi-altera.ko create device files without a call to register_chrdev(...).

How is it a loadable module without module_init(...)?

When I separately build spidev.c as an .ko and try loading it, I get: "Device or resourse busy"

---John

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

That's with:

root@arria10:~# lsmod
Module                  Size  Used by
spi_altera             16384  0
spidev                 20480  0
Quoted 114 lines · jchludzinski via lists.yoctoproject.org
root@arria10:~# find /sys/ -name 'spi*'

/sys/kernel/debug/clk/spi_m_clk
/sys/kernel/debug/tracing/events/spi /sys/kernel/debug/tracing/events/spi/spi_controller_idle /sys/kernel/debug/tracing/events/spi/spi_controller_busy /sys/kernel/debug/tracing/events/spi/spi_message_submit /sys/kernel/debug/tracing/events/spi/spi_message_start /sys/kernel/debug/tracing/events/spi/spi_message_done /sys/kernel/debug/tracing/events/spi/spi_transfer_start /sys/kernel/debug/tracing/events/spi/spi_transfer_stop /sys/kernel/debug/regmap/spi0.0 /sys/devices/platform/soc/ffda5000.spi/spi_master /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0 /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0 /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_sync /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_async /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_sync_immediate /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_sync /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_async /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_sync_immediate /sys/class/spidev
/sys/class/spi_master
/sys/class/spi_master/spi0
/sys/firmware/devicetree/base/__symbols__/spi2 /sys/firmware/devicetree/base/__symbols__/spi0 /sys/firmware/devicetree/base/__symbols__/spin_ctrl_1 /sys/firmware/devicetree/base/__symbols__/spi_m_clk /sys/firmware/devicetree/base/__symbols__/spi1 /sys/firmware/devicetree/base/__symbols__/spin_ctrl_2 /sys/firmware/devicetree/base/soc/spi@ff809000 /sys/firmware/devicetree/base/soc/spi@ffda5000 /sys/firmware/devicetree/base/soc/spi@ffda5000/resource-manager@0/spi-max-frequency /sys/firmware/devicetree/base/soc/clkmgr@ffd04000/clocks/spi_m_clk /sys/firmware/devicetree/base/soc/spi@ffda4000 /sys/firmware/devicetree/base/spi@0xc00c0800 /sys/firmware/devicetree/base/spi@0xc00c0800/spidev@0 /sys/firmware/devicetree/base/spi@0xc00c0800/spidev@0/spi-max-frequency /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@200/spin-controller /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@200/spin-rph /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@100/spin-controller /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@100/spin-controller-names /sys/firmware/devicetree/base/testcase-data-2/substation@100/motor-1/spin /sys/bus/platform/drivers/spi_altera
/sys/bus/spi
/sys/bus/spi/devices/spi0.0
/sys/bus/spi/drivers/spi-nor
/sys/bus/spi/drivers/altr_a10sr/spi0.0
/sys/bus/spi/drivers/spidev
/sys/module/spidev
/sys/module/spidev/drivers/spi:spidev
/sys/module/spi_altera

On 2021-03-18 03:44, Zoran wrote:

I am guessing here.... But what do you have while executing the following command being in /sys
as root?

root@arm:/sys# find . -name spi*

Zee
_______

On Wed, Mar 17, 2021 at 5:41 PM jchludzinski via lists.yoctoproject.org <[email protected]> wrote:

In the YOCTO/Linux source tree there's drivers/spi/ which has all the source for SPI drivers. There's only 1 file, spidev.c, which has:

static int __init spidev_init(void)
{
int status;

/* Claim our 256 reserved device numbers. Then register a class
* that will key udev/mdev to add/remove /dev nodes. Last, register
* the driver which manages those device numbers. */
BUILD_BUG_ON(N_SPI_MINORS > 256);
status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
if (status < 0)
return status;

spidev_class = class_create(THIS_MODULE, "spidev"); if (IS_ERR(spidev_class)) { unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
return PTR_ERR(spidev_class);
}

status = spi_register_driver(&spidev_spi_driver);
if (status < 0) {
class_destroy(spidev_class);
unregister_chrdev(SPIDEV_MAJOR,
spidev_spi_driver.driver.name);
}
return status;
}
module_init(spidev_init);

... for creating device files in udev.

So when I use 'make nconfig' to specifiy that I want a loadable module for the ALTERA SPI driver, why don't I see a spidev.o file in drivers/spi/ ?

How does spi-altera.ko create device files without a call to register_chrdev(...).

Quoted 7 lines

How is it a loadable module without module_init(...)?

When I separately build spidev.c as an .ko and try loading it, I
get: "Device or resourse busy"

---John

Links: You receive all messages sent to this group. View/Reply Online (#52767):
https://lists.yoctoproject.org/g/yocto/message/52767
Mute This Topic: https://lists.yoctoproject.org/mt/81407811/5071304
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub
[[email protected]]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

But there are NO udev files for the SPI devices defined in the DTSI file.

Quoted 138 lines · jchludzinski via lists.yoctoproject.org

That's with:

root@arria10:~# lsmod
Module                  Size  Used by
spi_altera             16384  0
spidev                 20480  0
Quoted 15 lines · jchludzinski via lists.yoctoproject.org
root@arria10:~# find /sys/ -name 'spi*'

/sys/kernel/debug/clk/spi_m_clk /sys/kernel/debug/tracing/events/spi /sys/kernel/debug/tracing/events/spi/spi_controller_idle /sys/kernel/debug/tracing/events/spi/spi_controller_busy /sys/kernel/debug/tracing/events/spi/spi_message_submit /sys/kernel/debug/tracing/events/spi/spi_message_start /sys/kernel/debug/tracing/events/spi/spi_message_done /sys/kernel/debug/tracing/events/spi/spi_transfer_start /sys/kernel/debug/tracing/events/spi/spi_transfer_stop /sys/kernel/debug/regmap/spi0.0 /sys/devices/platform/soc/ffda5000.spi/spi_master /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0 /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0

/sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_sync/sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_async/sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_sync_immediate/sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_sync/sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_async/sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_sync_immediate

Quoted 11 lines

/sys/class/spidev
/sys/class/spi_master /sys/class/spi_master/spi0 /sys/firmware/devicetree/base/__symbols__/spi2 /sys/firmware/devicetree/base/__symbols__/spi0 /sys/firmware/devicetree/base/__symbols__/spin_ctrl_1 /sys/firmware/devicetree/base/__symbols__/spi_m_clk /sys/firmware/devicetree/base/__symbols__/spi1 /sys/firmware/devicetree/base/__symbols__/spin_ctrl_2 /sys/firmware/devicetree/base/soc/spi@ff809000 /sys/firmware/devicetree/base/soc/spi@ffda5000

/sys/firmware/devicetree/base/soc/spi@ffda5000/resource-manager@0/spi-max-frequency

Quoted 4 lines

/sys/firmware/devicetree/base/soc/clkmgr@ffd04000/clocks/spi_m_clk /sys/firmware/devicetree/base/soc/spi@ffda4000 /sys/firmware/devicetree/base/spi@0xc00c0800 /sys/firmware/devicetree/base/spi@0xc00c0800/spidev@0

/sys/firmware/devicetree/base/spi@0xc00c0800/spidev@0/spi-max-frequency/sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@200/spin-controller/sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@200/spin-rph/sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@100/spin-controller/sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@100/spin-controller-names/sys/firmware/devicetree/base/testcase-data-2/substation@100/motor-1/spin

Quoted 78 lines

/sys/bus/platform/drivers/spi_altera
/sys/bus/spi
/sys/bus/spi/devices/spi0.0
/sys/bus/spi/drivers/spi-nor
/sys/bus/spi/drivers/altr_a10sr/spi0.0
/sys/bus/spi/drivers/spidev
/sys/module/spidev
/sys/module/spidev/drivers/spi:spidev
/sys/module/spi_altera

On 2021-03-18 03:44, Zoran wrote:

I am guessing here.... But what do you have while executing the following command being in /sys
as root?

root@arm:/sys# find . -name spi*

Zee
_______

On Wed, Mar 17, 2021 at 5:41 PM jchludzinski via lists.yoctoproject.org <[email protected]> wrote:

In the YOCTO/Linux source tree there's drivers/spi/ which has all the source for SPI drivers. There's only 1 file, spidev.c, which has:

static int __init spidev_init(void)
{
int status;

/* Claim our 256 reserved device numbers. Then register a class
* that will key udev/mdev to add/remove /dev nodes. Last, register
* the driver which manages those device numbers. */
BUILD_BUG_ON(N_SPI_MINORS > 256);
status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
if (status < 0)
return status;

spidev_class = class_create(THIS_MODULE, "spidev"); if (IS_ERR(spidev_class)) { unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
return PTR_ERR(spidev_class);
}

status = spi_register_driver(&spidev_spi_driver);
if (status < 0) {
class_destroy(spidev_class);
unregister_chrdev(SPIDEV_MAJOR,
spidev_spi_driver.driver.name);
}
return status;
}
module_init(spidev_init);

... for creating device files in udev.

So when I use 'make nconfig' to specifiy that I want a loadable module for the ALTERA SPI driver, why don't I see a spidev.o file in drivers/spi/ ?

How does spi-altera.ko create device files without a call to register_chrdev(...).

How is it a loadable module without module_init(...)?

When I separately build spidev.c as an .ko and try loading it, I
get: "Device or resourse busy"

---John

Quoted 7 lines

Links: You receive all messages sent to this group. View/Reply Online (#52767):
https://lists.yoctoproject.org/g/yocto/message/52767
Mute This Topic: https://lists.yoctoproject.org/mt/81407811/5071304
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub
[[email protected]]

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#52768): https://lists.yoctoproject.org/g/yocto/message/52768
Mute This Topic: https://lists.yoctoproject.org/mt/81407811/5071304
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub
[[email protected]]